#pragma once

#include <vector>
#include <map>
#include <dirent.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <memory>

#include "Dataset.h"

class Database : public virtual Dataset
{
private:
protected:
    map<int, std::shared_ptr<vector<palmprint>>> datas;
    virtual int get_person_id(string filename) const = 0;

public:
    using Dataset::Dataset;
    // Database(string dir) : Dataset(dir){};
    ~Database(){};

    virtual void load() = 0;
    virtual int next_radom_person(int person_id) = 0;
    virtual int next_person(int person_id) = 0;
    virtual int get_first_person() = 0;

    virtual std::shared_ptr<vector<palmprint>> getImages(int person_id)
    {
        return datas[person_id];
    };

    virtual int size()
    {
        int sum = 0;
        for (map<int, std::shared_ptr<vector<palmprint>>>::iterator i = datas.begin(); i != datas.end(); i++)
        {
            sum += (*i->second).size();
        }
        return sum;
    };

    virtual int person_num() { return datas.size(); };
};
